package com.css.zfzx.sjcj.modules.yhdisaster.service;

import com.css.zfzx.sjcj.modules.yhdisaster.viewobjects.QueueVO;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Scanner;

/**
 * @Description: zdyh_sjpg
 * @Author: lhl
 * @CreateDate: 2022/4/19 14:59
 */
@RestController
@RequestMapping("/queue")
public class QueueService {
    QueueVO queueVO = new QueueVO(3);

    @RequestMapping("/test1")
    public void main1() {
        Scanner scanner = new Scanner(System.in);
        System.out.print("--输入数据：");
        int data = scanner.nextInt();
        queueVO.addQueue(data);
        System.out.println("------入队列");
        test();
        queueVO.removeQueue();
        System.out.println("------出队列");
        System.out.println("----------结束");
    }

    @RequestMapping("/test2")
    public void main2() {
        queueVO.showQueue();
        System.out.println("------展示队列");
    }
    public void test() {
        long l = System.currentTimeMillis();
        System.out.println("----线程开始");
        for (int i = 0; i < 4; i++) {
            try {
                System.out.println("----线程睡眠第" + i + "次");
                Thread.sleep(40000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

        }
        long l1 = System.currentTimeMillis();
        System.out.println("----线程结束,耗时" + (l1 - l));
    }
}
